package cn.wolfcode.p2p.base.domain;

import cn.wolfcode.p2p.base.util.MaskUtil;
import com.alibaba.druid.support.json.JSONUtils;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

//实名认证实体类
@Getter@Setter
public class RealAuth extends BaseDomain{
    public static final int SEX_MALE = 0;//性别男
    public static final int SEX_FEMALE = 1;//性别女
    public static final int STATE_NORMAL = 0;//待审核
    public static final int STATE_PASS = 1;//审核通过
    public static final int STATE_REJECT = 2;//审核拒接
    private String realName;//真实姓名
    private int sex;//性别
    private String idNumber;//身份证号码
    private String bornDate;//出生年月
    private String address;//身份证地址
    private String image1;//身份证正面
    private String image2;//身份证反面

    private LoginInfo applier;//申请人
    private int state;//审核状态
    private LoginInfo auditor;//审核人
    private Date applyTime;//申请时间
    private Date auditTime;//审核时间
    private String remark;//审核备注

    public String getsexDisplay(){
        return this.sex==SEX_MALE?"男":"女";
    }

    public String getStateDisplay(){
        switch (this.state){
            case STATE_NORMAL:return "带审核";
            case STATE_PASS:return "审核通过";
            case STATE_REJECT:return "审核拒接";
            default:return "";
        }
    }

    public String getJsonString(){
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id",super.getId());
        map.put("applierName",applier.getUsername());
        map.put("realName",realName);
        map.put("idNumber",idNumber);
        map.put("sex",getsexDisplay());
        map.put("bornDate",bornDate);
        map.put("address",address);
        map.put("image1",image1);
        map.put("image2",image2);
        return JSONUtils.toJSONString(map);
    }

    public String getAnonymousRealName() {
        return MaskUtil.getAnonymousRealName(realName);
    }
    public String getAnonymousIdNumber() {
        return MaskUtil.getAnonymousIdNumber(idNumber);
    }
    public String getAnonymousAddress() {
        return MaskUtil.getAnonymousIdNumber(address);
    }


}
